﻿using AIStudio.Wpf.DiagramApp.Models;
using AIStudio.Wpf.DiagramApp.ViewModels;
using AIStudio.Wpf.Flowchart.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.ViewModels;

namespace AIStudio.Wpf.Flowchart
{
    public class MindViewModel : PageViewModel
    {
        public MindViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
        {
            
        }
        public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
        {          
            _service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
        }

        protected override void InitDiagramViewModel()
        {
            base.InitDiagramViewModel();

            DiagramViewModel.GridCellSize = new Size(100, 100);   
            _service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
            DiagramViewModel.AllowDrop = false;
        }

        protected override void Init()
        {
            base.Init();

            DesignerItemViewModelBase start = new MindLevel1Node() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, Text = "思维导图" };
            DiagramViewModel.DirectAddItemCommand.Execute(start);
            DiagramViewModel?.CenterMoveCommand.Execute(start);

            DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
          
        }

        public override void Dispose()
        {
            base.Dispose();

            foreach (var viewModel in DiagramViewModels)
            {
                FlowchartService.DisposeData(viewModel);
            }
        }
    }
}
